<template>
  <el-aside width="200px">
    <el-row class="tac">
      <el-col>
        <el-menu
          default-active="1"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
        >
          <el-menu-item index="1" @click="goPage('mycourse')">
            <template #title>
              <i class="el-icon-reading"></i>
              <span slot="title">我的课程</span>
            </template>
          </el-menu-item>

          <el-menu-item index="2" @click="goPage('mycartlist')">
            <template #title>
              <i class="el-icon-reading"></i>
              <span slot="title">我的订单</span>
            </template>
          </el-menu-item>

          <el-menu-item index="3" @click="goPage('myaccount')">
            <template #title>
              <i class="el-icon-edit"></i>
              <span slot="title">我的信息</span>
            </template>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </el-aside>
</template>

<script>
  var $this = {};
  export default {
    data() {
      return {};
    },
    beforeCreate() {
      $this = this;
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },

      goPage(link) {
        if (link === "mycourse") {
          $this.$router.push("/mycourse").catch(error => error);
        }else if(link === "myaccount") {
          $this.$router.push("/myaccount").catch(error => error);
        }else if(link === "mycartlist"){
          $this.$router.push("/mycartlist").catch(error => error);
        }
      }
    }
  };
</script>

<style scoped>
  .el-row{
    height: 100%;
  }

  .el-menu{
    border-right:none;
    margin-top: 30px;
    margin-bottom: 30px;
    min-width: 200px;
  }
  .el-aside{
    border-right: 1px solid #f5f1f1;
  }
</style>
